package com.pan.admin.module.loanProduct.controller;

import com.github.pagehelper.PageHelper;
import com.pan.admin.common.core.controller.BaseController;
import com.pan.admin.common.core.domain.AjaxResult;
import com.pan.admin.common.core.page.TableDataInfo;
import com.pan.admin.module.channel.service.LoanChannelService;
import com.pan.admin.module.loanProduct.entity.po.LoanProductApplyFlowPO;
import com.pan.admin.module.loanProduct.entity.qo.LoanProductApplyFlowQO;
import com.pan.admin.module.loanProduct.service.LoanProductApplyFlowService;
import com.pan.admin.module.loanProduct.service.LoanProductPlanService;
import com.pan.admin.module.loanProduct.service.LoanProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 机构进件流程
 *
 * @author caoxin
 */
@RestController
public class LoanProductApplyFlowController extends BaseController {

    @Autowired
    private LoanProductApplyFlowService loanProductApplyFlowService;
    @Autowired
    private LoanChannelService loanChannelService;
    @Autowired
    private LoanProductService loanProductService;
    @Autowired
    private LoanProductPlanService loanProductPlanService;

    /**
     * 渠道
     */
    @GetMapping("/product/applyFlow/listLoanChannel")
    @PreAuthorize("@ss.hasPermi('product:applyFlow:list')")
    public AjaxResult listLoanChannel(@RequestParam(required = false) String keyword) {
        return AjaxResult.success(this.loanChannelService.listLoanChannel(keyword));
    }

    /**
     * 主体
     */
    @GetMapping("/product/applyFlow/listLoanProduct")
    @PreAuthorize("@ss.hasPermi('product:applyFlow:list')")
    public AjaxResult listLoanProduct(@RequestParam(required = false) String keyword) {
        return AjaxResult.success(this.loanProductService.listLoanProduct(keyword));
    }

    /**
     * 计划
     */
    @GetMapping("/product/applyFlow/listLoanProductPlan")
    @PreAuthorize("@ss.hasPermi('product:applyFlow:list')")
    public AjaxResult listLoanProductPlan(@RequestParam(required = false) List<Long> loanProductId, @RequestParam(required = false) String keyword) {
        return AjaxResult.success(this.loanProductPlanService.listLoanProductPlan(loanProductId, keyword));
    }

    /**
     * 查询产品列表
     */
    @GetMapping("/product/applyFlow/list")
    @PreAuthorize("@ss.hasPermi('product:applyFlow:list')")
    public TableDataInfo list(LoanProductApplyFlowQO loanProductApplyFlowQO) {
        startPage();
        // 分页不执行count语句查询总行数
        PageHelper.getLocalPage().count(false);
        List<LoanProductApplyFlowPO> list = this.loanProductApplyFlowService.list(loanProductApplyFlowQO);
        return getDataTable(list);
    }

}
